import React from "react";
import { AppRegistry, Platform } from "react-native";
import moment from "moment";
import "moment/locale/zh-cn";

import Router, { routerMiddleware, routerReducer } from "./main";
import dva from "./utils/dva";
import models from "./models";
import _app from "./app";
import { name as appName } from "../app.json";

/* eslint-disable */
if (Platform.OS === "android") {
  // symbol polyfills
  global.Symbol = require("core-js/es6/symbol");
  require("core-js/fn/symbol/iterator");

  // collection fn polyfills
  require("core-js/fn/map");
  require("core-js/fn/set");
  require("core-js/fn/array/find");
}
/* eslint-enable */

moment.locale("zh-cn");

const app = dva({
  initialState: {},
  models: [...models],
  extraReducers: { router: routerReducer },
  onAction: [routerMiddleware],
  onError() {
    // console.log("onError", e);
  },
});

_app.setApp(app);

if (global.__DEV__) {
  // global.XMLHttpRequest = global.originalXMLHttpRequest
  //   ? global.originalXMLHttpRequest
  //   : global.XMLHttpRequest;
  // global.FormData = global.originalFormData
  //   ? global.originalFormData
  //   : global.FormData;
  // global.Blob = global.originalBlob ? global.originalBlob : global.Blob;
  // global.FileReader = global.originalFileReader
  //   ? global.originalFileReader
  //   : global.FileReader;
}

const App = app.start(<Router />);

// eslint-disable-next-line no-console
console.ignoredYellowBox = [
  "Warning: BackAndroid is deprecated. Please use BackHandler instead.",
  "source.uri should not be an empty string",
  "Invalid props.style key",
];

// eslint-disable-next-line no-console
console.disableYellowBox = true; // 关闭全部黄色警告

AppRegistry.registerComponent("rnapp", () => App);

AppRegistry.registerComponent(appName, () => App);

// export default app;
